package com.chinadrtv.batch.admin.jobs.ozing.question;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.validator.ValidationException;

import com.chinadrtv.user.model.UserFreeOzingOrder;
import com.chinadrtv.user.model.UserOzingOrder.OrderStatusType;

import java.util.Date;

public class FreeQuestionProcessor implements ItemProcessor<UserFreeOzingOrder, UserFreeOzingOrder> {
    private static Log log = LogFactory.getLog(FreeQuestionProcessor.class);
    
    @Override
    public UserFreeOzingOrder process(UserFreeOzingOrder order) throws Exception {
    	log.info("process --> " + order + "\t" + Thread.currentThread().getName());
    	
    	if (order.getCostOzingPoint() == null) {
			throw new ValidationException("Some bad data for " + null);
		}
    	// 一天内没有解答的离线问, 将锁定的星币退回(如果星卡过期,则增加一天有效期),order标记为取消
    	order.setOrderStatus(OrderStatusType.OrderStatusType_CANCEL);
        order.setLastModified(new Date());
        return order;
    }

}
